package com.tanhua.dubbo.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.BlackListMapper;
import com.tanhua.dubbo.mappers.UserInfoMapper;
import com.tanhua.model.db.BlackList;
import com.tanhua.model.db.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;
   //分页查询黑名单
    public IPage<UserInfo> findById(Long userId, Integer page, Integer pagesize) {
        Page<UserInfo> infoPage = new Page<>(page, pagesize);
        IPage<UserInfo> iPage =blackListMapper.findBlackList(infoPage,userId);
        return infoPage;
    }

    //移除黑名单
    public void deleteBlack(Long userId, Long id) {
        QueryWrapper<BlackList> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        wrapper.eq("black_user_id",id);
        blackListMapper.delete(wrapper);
    }
}
